package day10.net2;

import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.Socket;

public class Client {
    public static void main(String[] args) throws IOException {
        //1创建客户端套接字
        // 127.0.0.1:本地ip 也可以使用localhost
        Socket s = new Socket("192.168.88.2", 8888);

        //2调用getOutputStream获得输出流对象
        OutputStream os = s.getOutputStream();

        //3写数据到服务端
//		String str = "中国奥运会获得38金牌";
//		byte[] b = str.getBytes();
//		os.write(b);

        InputStream is = new FileInputStream("src\\main\\resources\\file.txt");
        byte[] b2 = new byte[10240000];
        int len = 0;
        while((len = is.read(b2))>0) {
            os.write(b2, 0, len);
        }

        //4关闭资源
        os.close();
        s.close();

    }
}
